<style scoped>
  .rj-topbar {
    height: 50px; line-height: 50px; background: #f7f7f7; text-align: center; font-size: 16px; border-bottom: 1px solid #bdbbbc; position: relative
  }
  .list {
    background: #eee;
  }
  .weui-form-preview {
    background-color: #fff;
    margin: 5px;
    border-radius: 5px;
  }
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .weui_navbar_item {
    font-size: 14px;
  }
  .weui_navbar_item.weui_bar_item_on {
    color: #3cc51f;
  }
  .weui-loadmore_line .weui-loadmore__tips {
    background-color: #eee;
  }
  .list {
    overflow: auto;
  }
  .rj-cell {
    display: inline-block;
    font-size: 0;
    padding: 5px 15px;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell.minpad{
    padding-right: 10px !important;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
  }
  .rj-cell span {
    padding-left: 5px;
    font-size: 14px;
    color: #333;
  }
  .rj-cell.note{
    width: 100%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cells {
    margin-top: 0;
  }
  .rj-wrap {
    background: #eee;
    overflow:auto;overflow-x: hidden
  }
  .rj-cont {
    background: #fff;
  }
  .weui-panel {
    background: #eee;
  }
  .rj-cont-tit {
    margin: 0;
    border-radius: 0;
  }
  .weui-panel {
    margin-top: 0;
    text-align: left;
  }
  .demos-content-padded {
    padding: 15px;
  }
  .attachimg {
    /*width: 100%;*/
  }
  .tipp {
    position: absolute;top: 0px;background: rgba(255,0,0,0.5);color:#fff;display: inline-block;width: 85px;text-align: center;
  }
  .rj-cell-child-tit {
    background: #f9f9f9;
    font-size: 14px;
    padding: 5px 15px;
    border-bottom: 1px solid #eee;
  }
  .tit label, .tit span {
    font-size: 16px;
  }
  .tit label {
    padding-right: 20px;
  }
  .weui-panel.weui-panel_access {
    padding-bottom: 10px;
  }
  .weui-panel__bd:not(.base) {
    width: 98%;
    padding: 0 1% 2px 1%;
  }
  .rj-cont-tit:not(.base) {
    border-radius: 5px;
  }
</style>
<template>
  <div class="viewpage">
    <div style="height: 50px; line-height: 50px; background: #f7f7f7; text-align: center; font-size: 16px; border-bottom: 1px solid #bdbbbc; position: relative">
      入库单详情
      <a href="javascript:;" @click="$router.back(-1)" style="position: absolute; left: 10px; top: 8px">
        <img src="../../assets/back.png" style="width: 20px" />
      </a>
    </div>
    <div class="weui-panel weui-panel_access">
      <div class="weui-panel__bd base">
        <div class="weui-form-preview billitem rj-cont-tit base">
          <div class="rj-cell max">
            <label>入库单编号：</label>
            <span>{{whinapply.code}}</span>
          </div>

          <div class="rj-cell max">
            <label>领料单编号：</label>
            <span>{{whinapply.pickinglistCode}}</span>
          </div>
          <div class="rj-cell max">
            <label>生产计划编号：</label>
            <span>{{whinapply.produceplanCode}}</span>
          </div>

          <div class="rj-cell max">
            <label>所属公司：</label>
            <span>{{whinapply.orgname}}</span>
          </div>
          <div class="rj-cell max">
            <label>所在班组：</label>
            <span>{{whinapply.department}}</span>
          </div>
          <div class="rj-cell max">
            <label>领料类别：</label>
            <span>{{whinapply.pickType == 1 ? '生产领料' : '二次加工'}}</span>
          </div>
          <div class="rj-cell max">
            <label>下单日期：</label>
            <span>{{whinapply.createtime}}</span>
          </div>
          <div class="rj-cell max">
            <label>出库库房：</label>
            <span>{{whinapply.strname}}</span>
          </div>
          <div class="rj-cell max">
            <label>状态：</label>
            <span>{{whinapply.statusName}}</span>
          </div>

          <div class="rj-cell ">
            <label>提交人：</label>
            <span>{{whinapply.operator}}</span>
          </div>
        </div>
      </div>
      <div class="weui-panel__hd" >入库单明细</div>
      <div class="weui-panel__bd" >
        <div class="weui-form-preview billitem rj-cont-tit">
          <div  style="border-top: 1px solid #eee;">
            <div  v-for="(item, index) in whinapply.items" :key="item.guid">
              <div class="rj-cell max">
                <label><span style="font-size: 14px;padding: 0;">产品：</span></label>
                <span>{{item.product}}</span>
                <span>{{item.spename}}</span>
                <span  v-show="item.weight != 0 ">{{item.weight}} 吨</span>

              </div>
              <div class="rj-cell " v-show="item.housename != '' ">
                <label><span style="font-size: 14px;padding: 0;">库房：</span></label>
                <span>{{item.housename}}</span>
              </div>

            </div>
            <div class="weui-media-box weui-media-box_text uploaderFiles" v-if="whiFormImg != undefined && whiFormImg.length > 0">
              <p class="exp" style="font-size: 12px;color: #999;padding: 5px 0;">入库单照片</p>
              <div class="exp uploaderFiles" style="display: inline-block;">
                <img class="attachimg" style="padding-right: 5px;"  v-for="(image, index) in whiFormImg" :key="image.guid"  alt="" onerror="javascript:this.src='../../../static/image/default.png';this.onerror = null" :src="image.url + '-suolue.png'" :data-img="image.url + '.png'" />
              </div>
            </div>
          </div>
        </div>
      </div>



      <div class="weui-panel__hd" ref="qaformTitle"  v-show="whinapply.status >=2" >质检单
<!--        <i class="weui-icon-cancel"    @click="delqaform(whinapply.guid)" style="float: right;" ></i>-->
      </div>
      <div class="weui-panel__bd"  v-show="whinapply.status >=2" ref="qaform">
        <div class="weui-form-preview billitem rj-cont-tit">
          <div    style="border-top: 1px solid #eee;">
            <div  >
              <div class="rj-cell max">
                <label><span style="font-size: 14px;padding: 0;">质检单编号：</span></label>
                <span>{{qaform.qacode}}</span>
              </div>
            </div>
            <div class="rj-cell max">
              <label>抽检数量：</label>
              <span>{{qaform.chkpknum}} 包</span>
              <span> {{qaform.chkwght}} Kg</span>

              <label>合格重量：</label>
              <span> {{qaform.okweight}} Kg</span>
            </div>
            <div class="rj-cell max">
              <label>不合格重量：</label>
              <span> {{qaform.notokweight}} Kg</span>
              <label>不合格率：</label>
              <span> {{qaform.unqualifiedchkrate}}%</span>
            </div>
            <div class="rj-cell max">
              <label>土杂重量：</label>
              <span> {{qaform.soilchkweight}} Kg</span>
              <label>土杂率：</label>
              <span> {{qaform.soilchkrate}}%</span>
            </div>

<!--            <div class="rj-cell max">-->
<!--              <label>大薯重量：</label>-->
<!--              <span> {{qaform.bigweight}} Kg</span>-->
<!--              <label>大薯率：</label>-->
<!--              <span> {{qaform.bigrate}}%</span>-->
<!--            </div>-->

            <br>
            <div class="rj-cell max">
              <label>合格率：</label>
              <span> {{ Number((100 - qaform.deductrate)).toFixed(2)}} %</span>
            </div>

            <div class="rj-cell max">
              <label>质检人：</label>
              <span>{{qaform.operatorname}}</span>

              <label>质检时间：</label>
              <span>{{qaform.createdate}}</span>
            </div>



            <div class="weui-media-box weui-media-box_text uploaderFiles" v-if="qaFormImg != undefined && qaFormImg.length > 0">
              <p class="exp" style="font-size: 12px;color: #999;padding: 5px 0;">质检单照片</p>
              <div class="exp uploaderFiles" style="display: inline-block;">
                <img class="attachimg" style="padding-right: 5px;"  v-for="(image, index) in qaFormImg" :key="image.guid"  alt="" onerror="javascript:this.src='../../../static/image/default.png';this.onerror = null" :src="image.url + '-suolue.png'" :data-img="image.url + '.png'" />
              </div>
            </div>
          </div>
        </div>
      </div>
      <OperationLogs :orderid="id"></OperationLogs>

    </div>
  </div>
</template>

<script>
  import CommonChart from "./CommonChart";
  import OperationLogs from '../common/OperationLogs'

  export default {
  name: 'ViewPickingList',
  components: {CommonChart},
  data () {
    return {
      openid: localStorage.openid,//'oIuV2v77MaLCAQILhjI6h6oTWpHI',
      userid: localStorage.userid,//'oIuV2v77MaLCAQILhjI6h6oTWpHI',
      id: '',
      picking: {},
      scraps: [],
      scrapweight: 0,
      whinforms: '',
      whinformweight: 0,
      failedwhs: [],
      failedweight: 0,
      maters: [],
      materweight: 0,
      outforms: [],
      outweight: 0,
      whinapply:{},
      item:[],
      qaform:{},
      qaFormImg:[],
        whiFormImg:[]

    }
  },
  components: {
    OperationLogs
  },
  created() {
    window.addEventListener('setItem', ()=> {
      this.openid = localStorage.getItem('openid');
      this.userid = localStorage.getItem('userid');
    })
  },
  mounted () {

    this.id = this.$route.query.id;
    this.getWhinapply(this.id);

    //图片浏览器
    $('.weui-panel').on('click', '.uploaderFiles .attachimg', function () {
      var num = $(this).parent().children().not( ".exp" ).length;
      var imgArr = [];
      for (var i=0; i<num; i++) {
        imgArr.push($(this).parent().find('.attachimg').eq(i).data('img'));
      }
      var pnum = $(this).parent().find('.exp').length;
      var index = pnum > 0 ? $(this).index() - pnum : $(this).index();
      var pb = $.photoBrowser({
        items: imgArr,
        initIndex: index
      });
      pb.open();
    });

  },
  methods: {
    getWhinapply: function (id) {
      this.axios({
        method: 'get',
        url: '/produce/Whinapply!getDetails.action?openid=' + this.openid,
        params: {guid: id}
      }).then(response => {


        if (response.data.status == 'success') {
          let data = response.data;
            console.log(data.info);
            this.whinapply=data.apply;
            if(data.qaForm != null ){
                this.qaform = data.qaForm;
            }
            if(data.qaFormImg != null ){
                this.qaFormImg = data.qaFormImg;
            }
            if(data.whiFormImg != null ){
                this.whiFormImg = data.whiFormImg;
            }

        } else {
          this.toastError('系统错误');
        }
      });
    },
      delqaform: function (guid) {
        let that = this;
        var object = Object;
        $.confirm("确定删除!", function() {
            that.axios({
                method: 'post',
                url: '/produce/Whinapply!delQaform.action?openid=' + localStorage.openid,
                params: {guid: guid}
            }).then((response) => {
                if (response.data.info == 'success') {

                    that.$refs['qaform'].remove();
                    that.$refs['qaformTitle'].remove();

                    this.toastSuccess('删除成功！');

                } else {
                    this.toastError("系统错误");
                }
            })
        }, function() {
            //点击取消后的回调函数
        });
      },


    }
}
</script>
